package com.fitnessapp.database;

import java.util.List;
import java.util.Map;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.widget.SimpleAdapter;

import com.fitnessapp.main.R;

public class AdapterFromQueryThread extends Thread {
	private Context context;
	private Handler handler;
	private ProgressDialog progress;
	private String select;
	private String from;
	private String where;
	
	public AdapterFromQueryThread(Context context, Handler handler, ProgressDialog progress,
			String select, String from, String where){
		this.context = context;
		this.handler = handler;
		this.select = select;
		this.from = from;
		this.where = where;
		this.progress = progress;
	}
	
	public void run(){
		
		MySqlHelper dbHelper = new MySqlHelper("http://brettsgameportfolio.com/SimplePHPQuery.php");
		List<Map<String,String>> result = dbHelper.query(select, from, where);			
	
		Message msg = new Message();
	//	msg.obj = new SimpleAdapter(context, result, R.layout.list_view_text_row,
		//		new String[]{"exercise_name"}, new int[]{R.id.rowText});

		handler.sendMessage(msg);
		
		progress.dismiss();
	}
}
